<?php include show_tpl('public_uheader.htm'); ?>

<div style="width:100%; height:20px; background:#E9ECF3;"></div>

<?php include show_tpl('public_usider.htm'); ?>

<!--{hook admin_user_update_start.htm}-->
<div id="page-wrapper" class="gray-bg">

	<div class="row wrapper wrapper-content">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">
							<em class="fa fa-list"></em>
							修改通道配置
						</div>
					</div>
					<div class="panel-body">
						<div class="content-box">
							<form class="form-ajax form-horizontal" id="form" action="<?php echo url('user-hebingadd'); ?>" method="get">
								<p style="font-size: 20px">修改通道配置</p>
								<div class="form-group">
									<label class="col-md-2 control-label">通道简称：</label>
									<div class="col-lg-6">
										<input type="text" name="a_shortname" class="form-control" placeholder="通道取一个易懂的简称(字母表示)" value="<?php echo $a['shortname']?>" >
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">通道名称：</label>
									<div class="col-lg-6">
										<input type="text" name="a_name" class="form-control" placeholder="通道取一个名字" value="<?php echo $a['name']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">支付宝APPID：</label>
									<div class="col-lg-6">
										<input type="text" name="a_api_id" class="form-control" placeholder="支付宝APPID" value="<?php echo $a['api_id']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">支付宝商户私钥：</label>
									<div class="col-lg-6">
										<input type="text" name="a_api_secret" class="form-control" placeholder="支付宝商户私钥(支付宝官网下载生成在上传)" value="<?php echo $a['api_secret']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">支付宝公匙：</label>
									<div class="col-lg-6">
										<input type="text" name="a_api_publickey" class="form-control" placeholder="支付宝公钥"  value="<?php echo $a['api_publickey']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">支付宝网关地址：</label>
									<div class="col-lg-6">
										<input type="text" name="a_url" class="form-control"  value="<?php echo $a['url']?>">
									</div>
								</div>
								<p style="font-size: 20px">修改附加信息</p>
								<!--<div class="form-group">-->
									<!--<label class="col-md-2 control-label">名称：</label>-->
									<!--<div class="col-lg-6">-->
									<!--</div>-->
								<!--</div>-->
								<input type="hidden" name="b_name" class="form-control"  value="<?php echo $b['name']?>">
								<div class="form-group">
									<label class="col-md-2 control-label">支付宝账户：</label>
									<div class="col-lg-6">
										<input type="text" name="b_alipay_account" placeholder="支付宝登录账户" class="form-control" value="<?php echo $b['alipay_account']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">姓名：</label>
									<div class="col-lg-6">
										<input type="text" name="b_alipay_realname" class="form-control" placeholder="姓名"  value="<?php echo $b['alipay_realname']?>">
									</div>
								</div>
								<!--<div class="form-group">-->
									<!--<label class="col-md-2 control-label">所属用户：</label>-->
									<!--<div class="col-lg-6">-->
										<!--<select id="b_user_id" name="b_user_id" class="form-control" readonly="readonly">-->
											<!--<?php foreach($users as $g){ ?>-->
											<!--<option value="<?php echo $g['uid'];?>" <?php echo $uid==$g['uid']?'selected':'';?> ><?php echo $g['username'];?></option>-->
											<!--<?php } ?>-->
										<!--</select>-->
									<!--</div>-->
								<!--</div>-->
								<input type="hidden" name="a_id" value="<?php echo $a['id']?>">
								<div class="form-group">
									<label class="col-md-2 control-label">单笔最大限额：</label>
									<div class="col-lg-6">
										<input type="text" name="b_max_limit" class="form-control" placeholder="单笔最大支付金额" value="<?php echo $b['max_limit']?>" >
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">通道最大限额：</label>
									<div class="col-lg-6">
										<input type="text" name="b_max_price" class="form-control" placeholder="通道最大收款金额"  value="<?php echo $b['max_price']?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">地区：</label>
									<div class="col-lg-6">
										<input type="text" name="b_area" placeholder="支付宝通道,所属地区多个逗号隔开(如:四川,重庆)" value="<?php echo $b['area'];?>" class="form-control" >

									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label">店铺分类：</label>
									<div class="col-lg-6">
										<select id="b_cate" name="b_cate" class="form-control selectpicker" data-live-search="true" data-style="btn-info">
											<option value="0">请选择分类</option>
											<?php foreach($cate as $c){ ?>
											<option value="<?php echo $c['id'];?>" <?php echo $b['cate']==$c['id']?'selected':'';?>><?php echo $c['name'];?></option>
											<?php } ?>
										</select>
									</div>
								</div>
								<!--<div class="form-group">-->
									<!--<label class="col-md-2 control-label">HOST：</label>-->
									<!--<div class="col-lg-6">-->
										<!--<input type="text"  name="b_host" class="form-control" value="<?php echo $b['host']?>">-->
									<!--</div>-->
								<!--</div>-->
								<div class="form-group">
									<label class="col-md-2 control-label">通道状态：</label>
									<div class="col-lg-6">
										<select id="b_is_open" name="b_is_open" class="form-control">
											<option value="1" <?php echo $b['is_open']==1?'selected':'';?>>开</option>
											<option value="0"  <?php echo $b['is_open']==0?'selected':'';?>>关</option>
										</select>
									</div>
								</div>
								<?php   if($conf['is_open_sms']){ ?>
								<div class="form-group">
									<label class="col-md-2 control-label">验证码(自动获取登陆账号电话)：</label>
									<div class="col-lg-6">
										<input type="text" style="width: 70%;float: left;" name="b_smscode" placeholder="请输入验证码" class="form-control" >
										<button type="button" id="sendsms" data-phone="<?php echo $user['info_mobile']?>" style="width: 25%;margin-left: 5%;float: left;height: 34px;">获取验证码</button>
										<div style="clear:both;"></div>
									</div>
								</div>
								<?php } ?>
								<div class="form-group row">
									<label class="col-sm-2 form-control-label"></label>
									<div class="col-sm-10">
										<button type="submit" class="btn btn-success" id="submit" data-loading-text="提交中...">确认</button>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!--<div id="page-wrapper" class="gray-bg">-->
	<!--<div class="col-lg-8 offset-lg-2">-->
		<!--<div class="card">-->
			<!--<div class="card-block">-->
				<!--<h4 class="card-title">添加通道</h4>-->
				<!--<div class="form-group row">-->
					<!--<label class="col-sm-2 form-control-label">安全码：</label>-->
					<!--<div class="col-sm-10">-->
						<!--<input type="password" id="b_passcode" name="b_passcode" class="form-control">-->
					<!--</div>-->
				<!--</div>-->

			<!--</div>-->
		<!--</div>-->
	<!--</div>-->
<!--</div>-->

<!--{hook admin_user_update_end.htm}-->

<?php include show_tpl('public_ufooter.htm'); ?>


<script>
var jform = $('#form');
var layer;
layui.use(['layer', 'form'], function(){
     layer = layui.layer
        ,form = layui.form;

});
$('#submit').click( function() {
    var postdata = jform.serialize()
	$.post(jform.attr('action'), postdata, function(data) {
        layer.alert(data.data, {icon: 1});
        if(data.code==1){
            setTimeout(function(){
                window.location.href="<?php echo url('user-channel')?>"
            }, 700);
		}else {

		}

	});
	return false;
});

$('#nav_pc li.user, #nav_mobile li.user').tab('show');
<?php   if($conf['is_open_sms']){ ?>
//发送验证码时添加cookie
function addCookie(name,value,expiresHours){
//判断是否设置过期时间,0代表关闭浏览器时失效
    if(expiresHours>0){
        var date=new Date();
        date.setTime(date.getTime()+expiresHours*1000);
        $.cookie(name, escape(value), {expires: date});
    }else{
        $.cookie(name, escape(value));
    }
}
//修改cookie的值
function editCookie(name,value,expiresHours){
    if(expiresHours>0){
        var date=new Date();
        date.setTime(date.getTime()+expiresHours*1000); //单位是毫秒
        $.cookie(name, escape(value), {expires: date});
    } else{
        $.cookie(name, escape(value));
    }
}
//根据名字获取cookie的值
function getCookieValue(name){
    return $.cookie(name);
}

v = getCookieValue("secondsremained");//获取cookie值
if(v>0){
    settime($("#sendsms"));//开始倒计时
}
var obj = $('#sendsms');
$(function(){
    $('#sendsms').click(function () {
        var phone = $(this).attr('data-phone');
        var sta1 = isPhoneNum(phone);
        if(sta1){
//            console.log(phone)
            $.post("<?php echo url('user-sendSms')?>",{phone:phone},function (data) {
                layer.alert(data.data, {icon: 1});
                if(data.code==1){

                    addCookie("secondsremained",90,90);//添加cookie记录,有效时间60s
                    settime(obj);//开始倒计时

                }else {

                }

            })
		}

    })

})



//开始倒计时
var countdown;
function settime(obj) {
    countdown=getCookieValue("secondsremained");
    console.log(countdown)
    if (countdown == undefined) {
        obj.removeAttr("disabled");
        obj.html("获取验证码");
        return;
    } else {
        obj.attr("disabled", true);
        obj.html("重新发送需要(" + countdown + ")");
        countdown--;
        editCookie("secondsremained",countdown,countdown+1);
    }
    setTimeout(function() { settime(obj) },1000) //每1000毫秒执行一次
}
//校验手机号是否合法
function isPhoneNum(phonenum){
    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
    if(!myreg.test(phonenum)){
        layer.alert('手机号不合法或者没有手机号', {icon: 1});
        return false;
    }else{
        return true;
    }
}
<?php }?>

</script>